/**
 * 
 */
package org.skyfree.ghyll.tcard.view;

import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.skyfree.ghyll.tcard.core.ITProject;
import org.skyfree.ghyll.tcard.core.ITWorkspace;
import org.skyfree.ghyll.tcard.core.TCardCore;

class WSViewContentProvider implements IStructuredContentProvider, ITreeContentProvider 
{
	
	ITWorkspace WSHandle = TCardCore.getDefault().getWorkSpace();
	
	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
		
	}
	public void dispose() {
	}
	public Object[] getElements(Object inputElement) 
	{
		return WSHandle.getProjects();
	}
	public Object[] getChildren(Object parentElement) 
	{
		System.out.println(parentElement.getClass());
		if(parentElement instanceof ITProject)
		{
			ITProject project = (ITProject)parentElement;
			return project.getAllWorkpiece();
		}
		else 
			return new Object[]{};
	}
	public Object getParent(Object element) {
		return null;
	}
	public boolean hasChildren(Object element) 
	{
		return getChildren(element).length > 0;
	}
}